//============================================================================
// Name        : llvmrun.cpp
// Author      : Vitya Sheremetov
// Version     : 0.9.6.2
// Copyright   : ETK-53M Inc.
// Description : McNobel LLVM IR execution engine in C++, Ansi-style
//============================================================================

#define VERSION "0.9.7.2"

#include <iostream>
#include "string.h"
#include "CFBIRExecuter.cpp"


int main(int argc, char *argv[])
{
	if(!argv[1])
	{
		std::cout<<"Error: missing operand.\n Use «llvmrun --help» for getting more info\n";
		exit(1);
	}

	if(strcmp(argv[1], "--help") == 0)
	{
		std::cout<<"Using: llvmrun filename\n"
				"Execute llvm IR code like llvm lli.\n\n"
				"Arguments:\n"
				"\t--help display this help and exit\n"
				"\t--version output version information and exit\n\n\n"
				"On any errors report at hostingshell@gmail.com\n"
				"Home page https://code.google.com/p/compiler-for-brainfuck/\n"
				"Get help with software GNU: <http://www.gnu.org/gethelp/>";
		return 1;
	}
	if(strcmp(argv[1], "--version") == 0)
	{
		std::cout<<"llvmrun "<<VERSION<<"\n"
				"Project home page https://code.google.com/p/compiler-for-brainfuck/\n"
				"Copyright (C) 2013 ETK-53M Inc.\n"
				"License GPLv3 +: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n"
				"This is free software: you can redistribute it and sell.\n";
		return 1;
	}

	CFBIRExecuter cfbexe;

	try
	{
		cfbexe.ReadIRFile(argv[1]);
	}
	catch(int e)
	{
		exit(1);
	}

	cfbexe.Execute();

	return 0;
}
